<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "shbb_trace_content".
 *
 * @property integer $id
 * @property integer $trace_type_id
 * @property string $index_name
 * @property string $index_descipt
 * @property integer $item_type_id
 *
 * @property ShbbBatchDetail[] $shbbBatchDetails
 * @property ShbbTraceType $traceType
 */
class TraceSystemContent extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'shbb_trace_system_content';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['trace_type_id', 'item_type_id'], 'integer'],
            [['index_name', 'index_descript'], 'string', 'max' => 255]
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'trace_type_id' => 'Trace Type ID',
            'index_name' => 'Index Name',
            'index_descript' => 'Index Descript',
            'item_type_id' => 'Item Type ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getShbbBatchDetails()
    {
        return $this->hasMany(ShbbBatchDetail::className(), ['target_aim_id' => 'id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getTraceType()
    {
        return $this->hasOne(ShbbTraceType::className(), ['id' => 'trace_type_id']);
    }
}
